package com.per.hjh.controller.base;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class BaseSpringCcontroller extends MultiActionController {
	@InitBinder
	  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
	    	binder.registerCustomEditor(Short.class, new CustomNumberEditor(Short.class, true));
	        binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, true));
	        binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, true));
	        binder.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, true));
	        binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, true));
	        binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, true));
	        binder.registerCustomEditor(BigInteger.class, new CustomNumberEditor(BigInteger.class, true));
	        binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));     
	  System.err.println("初始化binder的回调函数");  
	  }
}
